<!--suppress ALL -->
<include file="./Template/header.html" />
<link rel="stylesheet" type="text/css" href="/Template/css/orderList.css?v=2022102501">
<script type="text/javascript">

    $(function() {

        //初始化页面配置
        initPage("医院定制订单");

        var app = new Vue({
            el: '#container',
            data: {
                orderList: [],
            },
            methods: {
                checkRole: function(employeeRoleId, roleId) {
                    var employeeRoleArr = employeeRoleId.split(",");
                    var roleArr = roleId.split(",");

                    var result = false;
                    $.each(roleArr, function(i,val){
                        if($.inArray(val, employeeRoleArr) != -1 || $.inArray((parseInt(val)+100).toString(), employeeRoleArr) != -1){
                            result = true;
                        }
                    });
                    return result;
                },
                approve: function(orderId, status) {
                    var name = "";
                    if(status == -1){
                        name = "审批";
                    }else{
                        name = "拒绝";
                    }
                    if(confirm("请确认是否 [" + name + "] 该订单？")) {
                        $.ajax({
                            url: "/wechat/specialProduct/approve",
                            type: "post",
                            data: {
                                orderId: orderId,
                                status: status,
                            },
                            dataType: "JSON",
                            beforeSend: function () {
                                $("#loadingToast").show();
                            },
                            complete: function () {
                                $('#loadingToast').hide();
                            },
                            success:function(data){
                                if(!isNullOrEmpty(data.message)){
                                    alert(data.message);
                                }
                                window.location.href = "/wechat/specialProduct/orderList";
                            },
                            error:function(data){
                                window.location.href = "/wechat/specialProduct/orderList";
                            }
                        })
                    }else{
                        return false;
                    }
                },
                pay: function(orderId, price) {
                    if(confirm("请确认是否支付该订单？( " + price + "元 )")) {
                        window.location.href = "/wechat/userCenter/payInfo/id/"+orderId;
                    }else{
                        return false;
                    }
                },
            }
        })

        function getOrderList(status, ignoreOrderId) {

            $.ajax({
                url:"/wechat/specialProduct/myOrderList",
                type:"post",
                data:{
                    status: status,
                    orderId: '{$orderId}',
                    ignoreOrderId: ignoreOrderId
                },
                dataType:"JSON",
                beforeSend:function(){
                    $("#loadingToast").show();
                },
                complete:function(){
                    $('#loadingToast').hide();
                },
                success:function(data){
                    app.orderList = data;
                    setTimeout(function() {
                        $(".ui-item.measure-info img").bind("click", function() {
                            var upUrl = "/Template/images/icon-up.png";
                            var downUrl = "/Template/images/icon-down.png";
                            $(this).parent().next().toggle();
                            if($(this).attr("src") == upUrl) {
                                $(this).attr("src", downUrl);
                            } else {
                                $(this).attr("src", upUrl);
                            }
                        });
                        $(".ui-item.measure-info img").each(function() {
                            $(this).trigger("click");
                        });
                    },200);
                },
            })
        }

        $("#my-order ul li").bind("click", function() {

            if($(this).hasClass("active")) {
                return false;
            }

            var status = $(this).attr("data-status");

            $("#my-order ul li").each(function() {
                $(this).removeClass("active");
            });

            $(this).addClass("active");

            getOrderList(status, 1);

        });


        if(isNullOrEmpty("{$orderId}")){
            getOrderList(0);
        }else{
            getOrderList();
            $(".li-status-5").removeClass("active");
            $(".li-status-4").removeClass("active");
            $(".li-status-1").removeClass("active");
            $(".li-status1").removeClass("active");
            $(".li-status0").removeClass("active");
            switch('{$orderStatus}'){
                case '-5':
                    $(".li-status-5").attr("class","active");
                    break;
                case '-4':
                    $(".li-status-4").attr("class","active");
                    break;
                case '-1':
                    $(".li-status-1").attr("class","active");
                    break;
                case '1':
                    $(".li-status1").attr("class","active");
                    break;
                case '0':
                    $(".li-status0").attr("class","active");
                    break;
            }
        }

//        if (window.history && window.history.pushState) {
//            $(window).on('popstate', function () {
//                window.history.pushState('forward', null, '#');
//                window.history.forward(1);
//            });
//        }
//        window.history.pushState('forward', null, '#'); //在IE中必须得有这两行
//        window.history.forward(1);


    });


</script>
<div class="container" id="container">
    <div id="my-order">
        <ul>
            <!--li class="li-status-5" data-status="-5">
                <span>未付款</span>
            </li-->
            <li class="li-status-4" data-status="-4">
                <span>待审批</span>
            </li>
            <li class="li-status-1" data-status="-1">
                <span>待处理</span>
            </li>
            <li class="li-status1" data-status="1">
                <span>已核对</span>
            </li>
            <li class="li-status0 active" data-status="0">
                <span>全部</span>
            </li>
        </ul>
    </div>
    <div class="order-detail">
        <div class="no-data" v-if="orderList == null">暂无数据</div>
        <div class="order-info" v-for="order in orderList">
            <div class="status active" v-if="order.status == -1">
                <img src="/Template/images/icon-waiting.png" alt="">
                <span class="status-content">{{order.admin_name}} (待处理)</span>
            </div>
            <div class="status active" v-if="order.status == 1">
                <img src="/Template/images/icon-clock.png" alt="">
                <span class="status-content">{{order.admin_name}} (已核对)</span>
            </div>
            <div class="status active" v-if="order.status == -2">
                <img src="/Template/images/icon-clock.png" alt="">
                <span class="status-content">{{order.admin_name}} (已关闭)</span>
            </div>
            <div class="status active" v-if="order.status == -4">
                <img src="/Template/images/icon-approval.png" alt="">
                <span class="status-content">{{order.admin_name}} (待审批)</span>
            </div>
            <div class="status active" v-if="order.status == -5">
                <img src="/Template/images/icon-approval.png" alt="">
                <span class="status-content">{{order.admin_name}} (未付款)</span>
            </div>
            <div class="have-padding">
                <div class="product-info">
                    <img class="product-img" src="{{order.image_url}}" alt="product">
                    <div class="detail-info">
                        <p class="product-price" style="color: #d92f3b;font-weight: bold">￥{{order.sale_price}}</p>
                        <p class="product-name" style="font-weight: bold;">{{order.special_product_name}}</p>
                        <p class="number">×{{order.number}}</p>
                        <p class="buy-time">{{order.create_time}}</p>

                    </div>
                    <div>
                        <p class="singlePrice" style="color: #1cc385; width: 60%">[{{order.product_type}}] 原单价：{{order.single_price}}</p>
                        <p class="sum">共 <a style="color: #e97a15">{{order.number}}</a> 件商品 合计:<span style="color: #d92f3b;">￥{{order.total_price}}</span></p>
                    </div>

                </div>
                <div class="line"></div>
                <div class="user-order-info">
                    <div class="ui-item pickUp-info">
                        <span class="item-left">单号</span>
                        <span class="item-right">{{order.special_order_no}}</span>
                    </div>
                    <div v-if="order.agent_name != '无' && order.agent_name != ''">
                        <div class="ui-item pickUp-info">
                            <span class="item-left">渠道</span>
                            <span class="item-right">{{order.agent_name}}</span>
                        </div>
                    </div>
                    <!--div class="ui-item pickUp-info">
                        <span class="item-left">规格</span>
                        <span class="item-right" style="color: #45a1de;">{{order.size}}</span>
                    </div-->
                    <div class="ui-item pickUp-info">
                        <span class="item-left">数量</span>
                        <span class="item-right" style="color: #E97A15;">{{order.number}}</span>
                    </div>
                    <div v-if="order.agent_name == '无' || order.agent_name == '' || order.patient_name != ''">
                        <div class="ui-item pickUp-info">
                            <span class="item-left">医院信息</span>
                            <span class="item-right">科室：<a style="color: #E97A15">{{order.room}}</a>，医生：<a style="color: #1cc385">{{order.doctor_name}}</a></span>
                        </div>
                        <div class="ui-item pickUp-info">
                            <span class="item-left">患者信息</span>
                            <span class="item-right">姓名：<a style="color: #1cc385">{{order.patient_name}}</a>，ID：<a style="color: #E97A15">{{order.patient_id}}</a></span>
                        </div>
                    </div>
                    <div v-if="order.payment_type != ''">
                        <div class="ui-item pickUp-info">
                            <span class="item-left">付款情况</span>
                            <span class="item-right"><a style="color: #45A1DE">{{order.payment_type}}</a><a style="color: #e97a15" v-if="order.payment_type == '预付'"> ￥{{order.prepayment}}</a></span>
                        </div>
                    </div>
                    <div class="ui-item pickUp-info">
                        <span class="item-left">支具师</span>
                        <span class="item-right"><a style="color: #1cc385">{{order.prosthetist_name}}</a></span>
                    </div>
                    <div class="ui-item messege-left" v-if="order.note != ''">
                        <span class="item-left">留言备注</span>
                        <span class="item-right"><a style="color: #E97A15">{{order.note}}</a></span>
                    </div>
                    <!--div class="ui-item invoice-name" v-if="order.need_invoice == 2">
                        <span class="item-left">发票类型</span>
                        <span class="item-right"><a style="color: #45A1DE">个人</a></span>
                    </div>
                    <div class="ui-item invoice-name" v-if="order.need_invoice == 1">
                        <span class="item-left">发票类型</span>
                        <span class="item-right"><a style="color: #45A1DE">公司</a></span>
                    </div>
                    <div class="ui-item invoice-name" v-if="order.need_invoice == 1">
                        <span class="item-left">发票抬头</span>
                        <span class="item-right">{{order.invoice_name}}</span>
                    </div>
                    <div class="ui-item invoice-name" v-if="order.need_invoice == 1">
                        <span class="item-left">纳税人号</span>
                        <span class="item-right">{{order.invoice_number}}</span>
                    </div>
                    <div class="ui-item invoice-name" v-if="order.need_invoice != -1 && order.invoice_detail != ''">
                        <span class="item-left">发票明细</span>
                        <span class="item-right">{{order.invoice_detail}}</span>
                    </div-->
                    <div v-if="order.approve_id > 0">
                        <div class="ui-item pickUp-info">
                            <span class="item-left">审批人</span>
                            <span class="item-right" v-if="order.status != '-2'">{{order.approve_name}}<a style="color: #1dccaa">（通过）</a></span>
                            <span class="item-right" v-if="order.status == '-2'">{{order.approve_name}}<a style="color: #ee6f61">（未通过）</a></span>
                        </div>
                    </div>
                    <div class="ui-item pickUp-info" v-if="order.status == '-4' && checkRole('{$user.role}', '1')">
                        <span class="item-left"><button class="deny-button" v-on:click="approve(order.special_order_id, -2)">拒 绝</button></span>
                        <span class="item-right"><button class="approve-button" v-on:click="approve(order.special_order_id, -1)">审 批</button></span>
                    </div>
                    <div class="ui-item pickUp-info" v-if="order.status == '-5' && checkRole('{$user.employee_id}', order.employee_id)">
                        <span class="item-left"><button class="deny-button" style="display: none">站 位</button></span>
                        <span class="item-right"><button class="pay-button" v-on:click="pay(order.special_order_no, order.total_price)">支 付</button></span>
                    </div>
                </div>

                <!--div class="specialProduct-detail-info">
                    <div class="ui-item measure-info">
                        <span class="item-class">[{{order.delivery_type}}]</span>
                        <span class="item-detailname">发票信息</span>
                        <img class="icon-up" src="/Template/images/icon-up.png" alt="">
                    </div>
                    <div>
                        <div class="ui-item pick-own-address" v-if="order.delivery_type == '自提'">
                            <span class="item-left">自提地址</span>
                            <span class="item-right">{{order.receive_address}}</span>
                        </div>
                        <div class="ui-item pickUp-address" v-else>
                            <span class="item-left">收件人</span>
                            <span class="item-right">{{order.receive_name}}</span>
                        </div>
                        <div class="ui-item pickUp-address">
                            <span class="item-left">收件人</span>
                            <span class="item-right">{{order.receive_name}}，{{order.receive_contact}}</span>
                        </div>
                        <div v-if="order.delivery_type != '自提'">
                            <div class="ui-item pickUp-address">
                                <span class="item-left">收件地址</span>
                                <span class="item-right">{{order.receive_address}}</span>
                            </div>
                        </div>

                        <div class="ui-item fast-post" v-if="order.status == 1 && order.delivery_type != '自提'">
                            <span class="item-left">{{order.express_company}}</span>
                            <span class="item-right">{{order.delivery_name}}：{{order.delivery_number}}</span>
                        </div>
                    </div>
                </div-->
            </div>
        </div>
    </div>
</div>

<include file="./Template/footer.html" />

